package com.zlf.design_pattern.chain_filter.test1;

import com.zlf.design_pattern.chain_filter.test1.filter.Filter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/6/3.
 */
public class MessageProcessor {

    private List<Filter>  filters = new ArrayList<Filter>();

    public MessageProcessor addFilter(Filter filter){
        filters.add(filter);
        return this;
    }

    public String provcessor(String msg){

        String result = msg;
        for(Filter filter : filters) {
            result = filter.doFilter(result);
        }

        return result;
    }
}
